{% load static %}
<!DOCTYPE html>
<html>
<head>
    <title>My Blog</title>
    <link rel="stylesheet" type="text/css" href="{% static 'blog/styles.css' %}">
</head>
<body>
    <header>
        <div class="container">
            <div id="branding">
                <h1>我的博客</h1>
        </div>
        <nav>
            <url>
                <li><a href="/">首页</a></li>
                <li><a href="/admin">管理</a></li></li>
            </url>
        </nav>
    </header>
    <div class="container">
        <section class="article-list">
            <h1>文章列表</h1>

            {% for post in posts %}
            <article class="article">
                <h2><a href="{% url 'blog:post_detail' post.id %}">{{ post.title }}</a></h2>
                <div class="meta">
                    <span>作者: {{ post.author.username }}</span> | 
                    <span>发布时间: {{ post.created_at|date:"Y年m月d日" }}</span>
                </div>
                <div class="content">
                    {{ post.content|truncatewords:30 }}
                </div>
                <a href="{% url 'blog:post_detail' post.id %}" class="btn">阅读更多</a>
            </article>
        {% empty %} 
            <p>暂无文章。</p>
        {% endfor %}
        </section>
        
    </div>

    <footer>
        <p>我的博客 &copy; 2025</p>
    </footer>
</body>
</html>

  